import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		// 用户的登录信息
		userInfo: uni.getStorageSync('USERINFO') || {},
		// 查询到的结果
		resultInfo: uni.getStorageSync('RESULTINFO') || [],
	},
	mutations: {
		setUserInfo(state, userinfo) {
			state.userInfo = userinfo
		},
		setResultInfo(state, result) {
			state.resultInfo = result
		},
	},
	actions: {
		setUserInfo({ commit }, userinfo) {
			uni.setStorageSync('USERINFO', userinfo)
			commit('setUserInfo', userinfo)
		},
		setResultInfo({ commit }, result) {
			uni.setStorageSync('RESULTINFO', result)
			commit('setResultInfo', result)
		},
	},
	getters: {},
})
